﻿@using StandXunYouWeb.Model
@{
    var token = Context.Request.Cookies["token"];
    Users uModel = new Users();
    if (!string.IsNullOrEmpty(token))
    {
        var result = StandXunYouWeb.Utility.AESEncryptHelper.Decode(token);
        uModel = Newtonsoft.Json.JsonConvert.DeserializeObject<Users>(result);
    }
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>展览巡游--打卡有奖 — @ViewData["Title"]</title>

    <link href="https://cdnjs.cloudflare.com/ajax/libs/layui/2.12.0/css/layui.css" rel="stylesheet">
    <link rel="stylesheet" href="~/css/standyunyou.css" asp-append-version="true" />
</head>
<body style="margin: 0px;">

    <div class="box">
        @RenderBody()

        <div class="box-bottom frosted_glass">
            <div class="box-bottom-Home">首页</div>
            <div class="box-bottom-AnswerTopic">答题</div>
            <div class="box-bottom-MyPrize">我的奖品</div>
            @if (!string.IsNullOrEmpty(token))
            {
                <div class="box-bottom-LogOut">
                    <a href="/Account/LogOut">退出登录</a>
                </div>
            }
        </div>
    </div>

    <input type="hidden" id="uid" value="@uModel.UserIds" readonly="readonly" />
    <input type="hidden" id="isAnswer" value="0" readonly="readonly" />

    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/layui/2.12.0/layui.js"></script>

    <script>
        var baseURL = "https://localhost:44313";
        var uid = $('#uid').val();

        layui.config({
            base: '/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use('index');
        
        //回到首页
        $(document).on('click','.box-bottom-Home', function(){
            window.location.href = 'https://localhost:44312'
        })

        function userIsAnswer(){
            $.get(baseURL+ '/api/AnswerQuestions/UserIsAnswerAsync',{userId: uid }, function(res){
                if(res.data == 1){
                    $('.box-bottom-AnswerTopic').remove(); //移除答题按钮
                }
            })
        }
        if(uid != ""){
            userIsAnswer();
        }

        //前往答题
        $(document).on('click','.box-bottom-AnswerTopic', function(){
            if(uid == ""){
                layer.msg('请先登录');
            }
            else{
                window.location.href = 'https://localhost:44312/Home/AnswerQuestion'
            }
        })

        //前往我的奖品
        $(document).on('click','.box-bottom-MyPrize', function(){
            window.location.href = 'https://localhost:44312/Home/MyPrizes'
        })

        //前往登录
        $(document).on('click','.box-bottom-Login', function(){
            window.location.href = 'https://localhost:44312/Account/Login'
        })
        
    </script>
    
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>
